"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
var vue_1 = require("vue");
var vue_router_1 = require("vue-router");
var element_plus_1 = require("element-plus");
var icons_vue_1 = require("@element-plus/icons-vue");
var router = (0, vue_router_1.useRouter)();
// 所有支持的类型列表
var allTypes = [
    '销售单', '收款单', '采购单', '换货单',
    '退货单', '报损单', '报溢单', '盘点记录'
];
// 模拟草稿数据
var draftList = (0, vue_1.ref)([
    { id: 1, time: '2023-05-23 14:30', shopName: '一平云端', brand: 'GUCCI', type: '销售单' },
    { id: 2, time: '2023-05-23 11:20', shopName: '星辰美业', brand: 'CHANEL', type: '销售单' },
    { id: 3, time: '2023-05-22 09:45', shopName: '瑞丽坊', brand: 'DIOR', type: '采购单' },
    { id: 4, time: '2023-05-22 16:10', shopName: '一平云端', brand: 'GUCCI', type: '收款单' },
    { id: 5, time: '2023-05-21 15:30', shopName: '星辰美业', brand: 'YSL', type: '退货单' },
    { id: 6, time: '2023-05-21 10:05', shopName: '瑞丽坊', brand: 'DIOR', type: '报损单' },
]);
// 状态管理
var searchKey = (0, vue_1.ref)(''); // 搜索关键词
var selectedType = (0, vue_1.ref)(''); // 选中的类型（用于筛选）
var currentPage = (0, vue_1.ref)(1); // 当前页码
var pageSize = (0, vue_1.ref)(10); // 每页条数
// 筛选后的数据
var filteredDrafts = (0, vue_1.computed)(function () {
    var result = __spreadArray([], draftList.value, true);
    // 类型筛选
    if (selectedType.value) {
        result = result.filter(function (item) { return item.type === selectedType.value; });
    }
    // 搜索筛选
    if (searchKey.value) {
        var key_1 = searchKey.value.trim().toLowerCase();
        result = result.filter(function (item) {
            return item.shopName.toLowerCase().includes(key_1) ||
                item.brand.toLowerCase().includes(key_1) ||
                item.type.toLowerCase().includes(key_1);
        });
    }
    // 分页处理
    var startIndex = (currentPage.value - 1) * pageSize.value;
    return result.slice(startIndex, startIndex + pageSize.value);
});
// 总条数
var totalCount = (0, vue_1.computed)(function () {
    var result = __spreadArray([], draftList.value, true);
    if (selectedType.value)
        result = result.filter(function (item) { return item.type === selectedType.value; });
    if (searchKey.value) {
        var key_2 = searchKey.value.trim().toLowerCase();
        result = result.filter(function (item) {
            return item.shopName.toLowerCase().includes(key_2) ||
                item.brand.toLowerCase().includes(key_2) ||
                item.type.toLowerCase().includes(key_2);
        });
    }
    return result.length;
});
// 返回上一页
var handleBack = function () {
    router.back();
};
// 搜索
var handleSearch = function () {
    currentPage.value = 1;
};
// 类型筛选
var handleTypeFilter = function () {
    currentPage.value = 1; // 筛选后重置页码
};
// 查看草稿
var handleView = function (row) {
    router.push({ path: "/draft/".concat(row.id), query: { type: row.type } });
    element_plus_1.ElMessage.info("\u67E5\u770B\u8349\u7A3F\uFF1A".concat(row.shopName, " - ").concat(row.type));
};
// 删除草稿
var handleDelete = function (row) { return __awaiter(void 0, void 0, void 0, function () {
    var error_1;
    return __generator(this, function (_a) {
        switch (_a.label) {
            case 0:
                _a.trys.push([0, 2, , 3]);
                return [4 /*yield*/, element_plus_1.ElMessageBox.confirm("\u786E\u5B9A\u8981\u5220\u9664\u3010".concat(row.shopName, "\u3011\u7684").concat(row.type, "\u8349\u7A3F\u5417\uFF1F"), '删除确认', {
                        confirmButtonText: '确认删除',
                        cancelButtonText: '取消',
                        type: 'warning'
                    })];
            case 1:
                _a.sent();
                draftList.value = draftList.value.filter(function (item) { return item.id !== row.id; });
                element_plus_1.ElMessage.success('草稿已删除');
                return [3 /*break*/, 3];
            case 2:
                error_1 = _a.sent();
                return [3 /*break*/, 3];
            case 3: return [2 /*return*/];
        }
    });
}); };
// 分页-每页条数变更
var handleSizeChange = function (size) {
    pageSize.value = size;
    currentPage.value = 1;
};
// 分页-当前页变更
var handleCurrentChange = function (page) {
    currentPage.value = page;
};
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
var __VLS_ctx = __assign(__assign({}, {}), {});
var __VLS_elements;
var __VLS_components;
var __VLS_directives;
/** @type {__VLS_StyleScopedClasses['el-table']} */ ;
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)(__assign({ class: "draft-box-container" }));
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)(__assign({ class: "page-header" }));
__VLS_asFunctionalElement(__VLS_elements.h2, __VLS_elements.h2)(__assign({ class: "page-title" }));
var __VLS_0 = {}.ElButton;
/** @type {[typeof __VLS_components.ElButton, typeof __VLS_components.elButton, typeof __VLS_components.ElButton, typeof __VLS_components.elButton, ]} */ ;
// @ts-ignore
ElButton;
// @ts-ignore
var __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0(__assign({ 'onClick': {} }, { type: "default" })));
var __VLS_2 = __VLS_1.apply(void 0, __spreadArray([__assign({ 'onClick': {} }, { type: "default" })], __VLS_functionalComponentArgsRest(__VLS_1), false));
var __VLS_4;
var __VLS_5;
var __VLS_6 = ({ click: {} },
    { onClick: (__VLS_ctx.handleBack) });
var __VLS_7 = __VLS_3.slots.default;
// @ts-ignore
[handleBack,];
var __VLS_3;
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)(__assign({ class: "search-bar" }));
var __VLS_8 = {}.ElInput;
/** @type {[typeof __VLS_components.ElInput, typeof __VLS_components.elInput, ]} */ ;
// @ts-ignore
ElInput;
// @ts-ignore
var __VLS_9 = __VLS_asFunctionalComponent(__VLS_8, new __VLS_8(__assign(__assign({ 'onKeyup': {} }, { modelValue: (__VLS_ctx.searchKey), placeholder: "请输入关键词搜索" }), { class: "search-input" })));
var __VLS_10 = __VLS_9.apply(void 0, __spreadArray([__assign(__assign({ 'onKeyup': {} }, { modelValue: (__VLS_ctx.searchKey), placeholder: "请输入关键词搜索" }), { class: "search-input" })], __VLS_functionalComponentArgsRest(__VLS_9), false));
var __VLS_12;
var __VLS_13;
var __VLS_14 = ({ keyup: {} },
    { onKeyup: (__VLS_ctx.handleSearch) });
// @ts-ignore
[searchKey, handleSearch,];
var __VLS_11;
var __VLS_16 = {}.ElButton;
/** @type {[typeof __VLS_components.ElButton, typeof __VLS_components.elButton, typeof __VLS_components.ElButton, typeof __VLS_components.elButton, ]} */ ;
// @ts-ignore
ElButton;
// @ts-ignore
var __VLS_17 = __VLS_asFunctionalComponent(__VLS_16, new __VLS_16(__assign({ 'onClick': {} }, { type: "primary" })));
var __VLS_18 = __VLS_17.apply(void 0, __spreadArray([__assign({ 'onClick': {} }, { type: "primary" })], __VLS_functionalComponentArgsRest(__VLS_17), false));
var __VLS_20;
var __VLS_21;
var __VLS_22 = ({ click: {} },
    { onClick: (__VLS_ctx.handleSearch) });
var __VLS_23 = __VLS_19.slots.default;
// @ts-ignore
[handleSearch,];
var __VLS_24 = {}.ElIcon;
/** @type {[typeof __VLS_components.ElIcon, typeof __VLS_components.elIcon, typeof __VLS_components.ElIcon, typeof __VLS_components.elIcon, ]} */ ;
// @ts-ignore
ElIcon;
// @ts-ignore
var __VLS_25 = __VLS_asFunctionalComponent(__VLS_24, new __VLS_24({
    size: (16),
}));
var __VLS_26 = __VLS_25.apply(void 0, __spreadArray([{
        size: (16),
    }], __VLS_functionalComponentArgsRest(__VLS_25), false));
var __VLS_28 = __VLS_27.slots.default;
var __VLS_29 = {}.Search;
/** @type {[typeof __VLS_components.Search, ]} */ ;
// @ts-ignore
icons_vue_1.Search;
// @ts-ignore
var __VLS_30 = __VLS_asFunctionalComponent(__VLS_29, new __VLS_29({}));
var __VLS_31 = __VLS_30.apply(void 0, __spreadArray([{}], __VLS_functionalComponentArgsRest(__VLS_30), false));
var __VLS_27;
var __VLS_19;
var __VLS_34 = {}.ElTable;
/** @type {[typeof __VLS_components.ElTable, typeof __VLS_components.elTable, typeof __VLS_components.ElTable, typeof __VLS_components.elTable, ]} */ ;
// @ts-ignore
ElTable;
// @ts-ignore
var __VLS_35 = __VLS_asFunctionalComponent(__VLS_34, new __VLS_34(__assign({ data: (__VLS_ctx.filteredDrafts), border: true, stripe: true }, { style: {} })));
var __VLS_36 = __VLS_35.apply(void 0, __spreadArray([__assign({ data: (__VLS_ctx.filteredDrafts), border: true, stripe: true }, { style: {} })], __VLS_functionalComponentArgsRest(__VLS_35), false));
var __VLS_38 = __VLS_37.slots.default;
// @ts-ignore
[filteredDrafts,];
var __VLS_39 = {}.ElTableColumn;
/** @type {[typeof __VLS_components.ElTableColumn, typeof __VLS_components.elTableColumn, ]} */ ;
// @ts-ignore
ElTableColumn;
// @ts-ignore
var __VLS_40 = __VLS_asFunctionalComponent(__VLS_39, new __VLS_39({
    label: "序号",
    type: "index",
    align: "center",
    width: "80",
}));
var __VLS_41 = __VLS_40.apply(void 0, __spreadArray([{
        label: "序号",
        type: "index",
        align: "center",
        width: "80",
    }], __VLS_functionalComponentArgsRest(__VLS_40), false));
var __VLS_44 = {}.ElTableColumn;
/** @type {[typeof __VLS_components.ElTableColumn, typeof __VLS_components.elTableColumn, ]} */ ;
// @ts-ignore
ElTableColumn;
// @ts-ignore
var __VLS_45 = __VLS_asFunctionalComponent(__VLS_44, new __VLS_44({
    label: "时间",
    prop: "time",
    align: "center",
}));
var __VLS_46 = __VLS_45.apply(void 0, __spreadArray([{
        label: "时间",
        prop: "time",
        align: "center",
    }], __VLS_functionalComponentArgsRest(__VLS_45), false));
var __VLS_49 = {}.ElTableColumn;
/** @type {[typeof __VLS_components.ElTableColumn, typeof __VLS_components.elTableColumn, ]} */ ;
// @ts-ignore
ElTableColumn;
// @ts-ignore
var __VLS_50 = __VLS_asFunctionalComponent(__VLS_49, new __VLS_49({
    label: "美容院",
    prop: "shopName",
    align: "center",
}));
var __VLS_51 = __VLS_50.apply(void 0, __spreadArray([{
        label: "美容院",
        prop: "shopName",
        align: "center",
    }], __VLS_functionalComponentArgsRest(__VLS_50), false));
var __VLS_54 = {}.ElTableColumn;
/** @type {[typeof __VLS_components.ElTableColumn, typeof __VLS_components.elTableColumn, ]} */ ;
// @ts-ignore
ElTableColumn;
// @ts-ignore
var __VLS_55 = __VLS_asFunctionalComponent(__VLS_54, new __VLS_54({
    label: "品牌",
    prop: "brand",
    align: "center",
}));
var __VLS_56 = __VLS_55.apply(void 0, __spreadArray([{
        label: "品牌",
        prop: "brand",
        align: "center",
    }], __VLS_functionalComponentArgsRest(__VLS_55), false));
var __VLS_59 = {}.ElTableColumn;
/** @type {[typeof __VLS_components.ElTableColumn, typeof __VLS_components.elTableColumn, typeof __VLS_components.ElTableColumn, typeof __VLS_components.elTableColumn, ]} */ ;
// @ts-ignore
ElTableColumn;
// @ts-ignore
var __VLS_60 = __VLS_asFunctionalComponent(__VLS_59, new __VLS_59({
    align: "center",
}));
var __VLS_61 = __VLS_60.apply(void 0, __spreadArray([{
        align: "center",
    }], __VLS_functionalComponentArgsRest(__VLS_60), false));
var __VLS_63 = __VLS_62.slots.default;
{
    var __VLS_64 = __VLS_62.slots.header;
    var __VLS_65 = {}.ElSelect;
    /** @type {[typeof __VLS_components.ElSelect, typeof __VLS_components.elSelect, typeof __VLS_components.ElSelect, typeof __VLS_components.elSelect, ]} */ ;
    // @ts-ignore
    ElSelect;
    // @ts-ignore
    var __VLS_66 = __VLS_asFunctionalComponent(__VLS_65, new __VLS_65(__assign(__assign({ 'onChange': {} }, { modelValue: (__VLS_ctx.selectedType), placeholder: "类型", size: "small" }), { class: "header-type-select" })));
    var __VLS_67 = __VLS_66.apply(void 0, __spreadArray([__assign(__assign({ 'onChange': {} }, { modelValue: (__VLS_ctx.selectedType), placeholder: "类型", size: "small" }), { class: "header-type-select" })], __VLS_functionalComponentArgsRest(__VLS_66), false));
    var __VLS_69 = void 0;
    var __VLS_70 = void 0;
    var __VLS_71 = ({ change: {} },
        { onChange: (__VLS_ctx.handleTypeFilter) });
    var __VLS_72 = __VLS_68.slots.default;
    // @ts-ignore
    [selectedType, handleTypeFilter,];
    var __VLS_73 = {}.ElOption;
    /** @type {[typeof __VLS_components.ElOption, typeof __VLS_components.elOption, ]} */ ;
    // @ts-ignore
    ElOption;
    // @ts-ignore
    var __VLS_74 = __VLS_asFunctionalComponent(__VLS_73, new __VLS_73({
        value: "",
        label: "类型",
    }));
    var __VLS_75 = __VLS_74.apply(void 0, __spreadArray([{
            value: "",
            label: "类型",
        }], __VLS_functionalComponentArgsRest(__VLS_74), false));
    for (var _i = 0, _a = __VLS_getVForSourceType((__VLS_ctx.allTypes)); _i < _a.length; _i++) {
        var type = _a[_i][0];
        // @ts-ignore
        [allTypes,];
        var __VLS_78 = {}.ElOption;
        /** @type {[typeof __VLS_components.ElOption, typeof __VLS_components.elOption, ]} */ ;
        // @ts-ignore
        ElOption;
        // @ts-ignore
        var __VLS_79 = __VLS_asFunctionalComponent(__VLS_78, new __VLS_78({
            key: (type),
            label: (type),
            value: (type),
        }));
        var __VLS_80 = __VLS_79.apply(void 0, __spreadArray([{
                key: (type),
                label: (type),
                value: (type),
            }], __VLS_functionalComponentArgsRest(__VLS_79), false));
    }
    var __VLS_68;
}
{
    var __VLS_83 = __VLS_62.slots.default;
    var scope = __VLS_getSlotParameters(__VLS_83)[0];
    (scope.row.type || '-');
}
var __VLS_62;
var __VLS_84 = {}.ElTableColumn;
/** @type {[typeof __VLS_components.ElTableColumn, typeof __VLS_components.elTableColumn, typeof __VLS_components.ElTableColumn, typeof __VLS_components.elTableColumn, ]} */ ;
// @ts-ignore
ElTableColumn;
// @ts-ignore
var __VLS_85 = __VLS_asFunctionalComponent(__VLS_84, new __VLS_84({
    label: "操作",
    align: "center",
}));
var __VLS_86 = __VLS_85.apply(void 0, __spreadArray([{
        label: "操作",
        align: "center",
    }], __VLS_functionalComponentArgsRest(__VLS_85), false));
var __VLS_88 = __VLS_87.slots.default;
{
    var __VLS_89 = __VLS_87.slots.default;
    var scope_1 = __VLS_getSlotParameters(__VLS_89)[0];
    var __VLS_90 = {}.ElButton;
    /** @type {[typeof __VLS_components.ElButton, typeof __VLS_components.elButton, typeof __VLS_components.ElButton, typeof __VLS_components.elButton, ]} */ ;
    // @ts-ignore
    ElButton;
    // @ts-ignore
    var __VLS_91 = __VLS_asFunctionalComponent(__VLS_90, new __VLS_90(__assign({ 'onClick': {} }, { type: "primary" })));
    var __VLS_92 = __VLS_91.apply(void 0, __spreadArray([__assign({ 'onClick': {} }, { type: "primary" })], __VLS_functionalComponentArgsRest(__VLS_91), false));
    var __VLS_94 = void 0;
    var __VLS_95 = void 0;
    var __VLS_96 = ({ click: {} },
        { onClick: function () {
                var _a = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    _a[_i] = arguments[_i];
                }
                var $event = _a[0];
                __VLS_ctx.handleView(scope_1.row);
                // @ts-ignore
                [handleView,];
            } });
    var __VLS_97 = __VLS_93.slots.default;
    var __VLS_93;
    var __VLS_98 = {}.ElButton;
    /** @type {[typeof __VLS_components.ElButton, typeof __VLS_components.elButton, typeof __VLS_components.ElButton, typeof __VLS_components.elButton, ]} */ ;
    // @ts-ignore
    ElButton;
    // @ts-ignore
    var __VLS_99 = __VLS_asFunctionalComponent(__VLS_98, new __VLS_98(__assign({ 'onClick': {} }, { type: "danger" })));
    var __VLS_100 = __VLS_99.apply(void 0, __spreadArray([__assign({ 'onClick': {} }, { type: "danger" })], __VLS_functionalComponentArgsRest(__VLS_99), false));
    var __VLS_102 = void 0;
    var __VLS_103 = void 0;
    var __VLS_104 = ({ click: {} },
        { onClick: function () {
                var _a = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    _a[_i] = arguments[_i];
                }
                var $event = _a[0];
                __VLS_ctx.handleDelete(scope_1.row);
                // @ts-ignore
                [handleDelete,];
            } });
    var __VLS_105 = __VLS_101.slots.default;
    var __VLS_101;
}
var __VLS_87;
var __VLS_37;
var __VLS_106 = {}.ElPagination;
/** @type {[typeof __VLS_components.ElPagination, typeof __VLS_components.elPagination, ]} */ ;
// @ts-ignore
ElPagination;
// @ts-ignore
var __VLS_107 = __VLS_asFunctionalComponent(__VLS_106, new __VLS_106(__assign(__assign(__assign({ 'onSizeChange': {} }, { 'onCurrentChange': {} }), { currentPage: (__VLS_ctx.currentPage), pageSizes: ([5, 10, 20, 50]), pageSize: (__VLS_ctx.pageSize), layout: "total, sizes, prev, pager, next, jumper", total: (__VLS_ctx.totalCount) }), { style: {} })));
var __VLS_108 = __VLS_107.apply(void 0, __spreadArray([__assign(__assign(__assign({ 'onSizeChange': {} }, { 'onCurrentChange': {} }), { currentPage: (__VLS_ctx.currentPage), pageSizes: ([5, 10, 20, 50]), pageSize: (__VLS_ctx.pageSize), layout: "total, sizes, prev, pager, next, jumper", total: (__VLS_ctx.totalCount) }), { style: {} })], __VLS_functionalComponentArgsRest(__VLS_107), false));
var __VLS_110;
var __VLS_111;
var __VLS_112 = ({ sizeChange: {} },
    { onSizeChange: (__VLS_ctx.handleSizeChange) });
var __VLS_113 = ({ currentChange: {} },
    { onCurrentChange: (__VLS_ctx.handleCurrentChange) });
// @ts-ignore
[currentPage, pageSize, totalCount, handleSizeChange, handleCurrentChange,];
var __VLS_109;
/** @type {__VLS_StyleScopedClasses['draft-box-container']} */ ;
/** @type {__VLS_StyleScopedClasses['page-header']} */ ;
/** @type {__VLS_StyleScopedClasses['page-title']} */ ;
/** @type {__VLS_StyleScopedClasses['search-bar']} */ ;
/** @type {__VLS_StyleScopedClasses['search-input']} */ ;
/** @type {__VLS_StyleScopedClasses['header-type-select']} */ ;
var __VLS_export = (await Promise.resolve().then(function () { return require('vue'); })).defineComponent({});
exports.default = {};
